package com.example.order_system.controller;

import com.example.order_system.model.Dish;
import com.example.order_system.util.ResultData;
import com.example.order_system.service.OrderDetailService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;
import java.util.List;

/**
 * @description:
 * @author: chengbaiyi
 * @create: 2022-07-22 19:38
 */
@RestController
@RequestMapping("/ordetail")
public class OrderDetailController {
    @Autowired
    private OrderDetailService orderDetailService;

    @GetMapping("/orderdetail")
    public ResultData orderDetail(int oid) {
        int state = -1;
        List<Dish> data = new ArrayList<>();
        String msg = "未知错误";
        if (oid > 0) {
            data = orderDetailService.orderDetail(oid);
            state = 200;
            msg = "查询成功";
        }
        return new ResultData(state, data, msg);
    }
}
